/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode(int x) { val = x; }
 * }
 */
class Solution {
  public ListNode getKthFromEnd(ListNode head, int k) {
      ListNode slow = head;
      ListNode fast = head;
      while(k--!=0){
          fast=fast.next;
      }
      while(fast!=null){
          slow = slow.next;
          fast = fast.next;
      }
      return slow;
  }
}